home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / AppsToGo / DTS.Draw / TExtSelectObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  3.1 KB  |  141 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TExtSelectObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  20. ** on this function. */
  21.  
  22. /* This file implements the messages for the round-rect object.  Many of the messages
  23. ** can be handled by the rect object, as they deal with a rect structure.  Only
  24. ** a few of them are round-rect-specific. */
  25.  
  26. /* It would seem that you would want a custom hit-test message handler here, but
  27. ** the rect object first checks to see if the hit is within the bounding box of
  28. ** the object, and if so, it then calls the object to return the region.  This
  29. ** allows the rect object to generically handle hit-testing. */
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34.  
  35.  
  36.  
  37. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  38. #include "App.protos.h"        /* Get the prototypes for the application.        */
  39.  
  40. #ifndef __OSEVENTS__
  41. #include <OSEvents.h>
  42. #endif
  43.  
  44. #ifndef __OSUTILS__
  45. #include <OSUtils.h>
  46. #endif
  47.  
  48. #ifndef __QUICKDRAW__
  49. #include <Quickdraw.h>
  50. #endif
  51.  
  52. #ifndef __STRING__
  53. #include <String.h>
  54. #endif
  55.  
  56. #ifndef __TREEOBJ2__
  57. #include "TreeObj2.h"
  58. #endif
  59.  
  60. #ifndef __UTILITIES__
  61. #include "Utilities.h"
  62. #endif
  63.  
  64.  
  65.  
  66. #pragma segment DrawObjects
  67. long    TExtSelectObj(TreeObjHndl hndl, short message, long data)
  68. {
  69.     Rect        rct;
  70.     RgnHandle    rgn, accumRgn;
  71.  
  72.     switch (message) {
  73.         case FREEMESSAGE:
  74.         case COPYMESSAGE:
  75.         case UNDOMESSAGE:
  76.         case CONVERTMESSAGE:
  77.         case FREADMESSAGE:
  78.         case FWRITEMESSAGE:
  79.         case HREADMESSAGE:
  80.         case HWRITEMESSAGE:
  81.         case HITTESTMESSAGE:
  82.         case GETOBJRECTMESSAGE:
  83.         case SETOBJRECTMESSAGE:
  84.         case SECTOBJRECTMESSAGE:
  85.         case GETBBOXMESSAGE:
  86.         case CLICKMESSAGE:
  87.         case KEYMESSAGE:
  88.         case SETSELECTMESSAGE:
  89.         case GETSELECTMESSAGE:
  90.         case SIZEMESSAGE:
  91.         case COMPAREMESSAGE:
  92.             return(TRectObj(hndl, message, data));
  93.             break;
  94.  
  95.         case INITMESSAGE:
  96.             break;
  97.  
  98.         case GETRGNMESSAGE:
  99.             rgn      = NewRgn();
  100.             accumRgn = (RgnHandle)data;
  101.             if (accumRgn)
  102.                 if (GetHandleSize((Handle)accumRgn) > 10000)
  103.                     return((long)rgn);
  104.             rct = mDerefCommon(hndl)->rect;
  105.             RectRgn(rgn, &rct);
  106.             if (accumRgn)
  107.                 UnionRgn(rgn, accumRgn, accumRgn);
  108.             return((long)rgn);
  109.             break;
  110.  
  111.         case DRAWMESSAGE:
  112.             rct = mDerefRRect(hndl)->rect;
  113.             switch (data) {
  114.                 case DRAWOBJ:
  115.                     PenMode(patXor);
  116.                     PenPat((ConstPatternParam)&qd.gray);
  117.                     FrameRect(&rct);
  118.                     PenNormal();
  119.                     break;
  120.                 case ERASEOBJ:
  121.                     EraseRect(&rct);
  122.                     break;
  123.             }
  124.             break;
  125.  
  126.         case PRINTMESSAGE:
  127.             break;
  128.  
  129.         case VHMESSAGE:
  130.             break;
  131.  
  132.         default:
  133.             break;
  134.     }
  135.  
  136.     return(noErr);
  137. }
  138.  
  139.  
  140.  
  141.